/*
 * @Date: 2025-09-09 11:23:16
 * @Auth: 873768511@qq.com
 * @LastEditors: 463997479@qq.com
 * @LastEditTime: 2025-09-27 23:56:00
 * @FilePath: \corpus\src\pages\resourceManagement\list\component\DetailDrawer\index.tsx
 */
import { ProColumns, ProTable } from '@ant-design/pro-components';
import { Drawer, Space } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import hooks from '../../hooks';
import useProTableConfig from '../../hooks/useProTableConfig';
import styles from './index.less';
import TableData from './TableData';

export default () => {
  const {
    drawerDetail,
    drawerDetailToggle,
    drawerTask,
    getFileTaskPageContent,
    drawerTaskToggle,
    getFilePageContent,
    resourceKnowledgeData,
  } = hooks.useContainer();

  const proTableConfig = useProTableConfig({
    optionRender(config, props, dom) {
      return [...dom.reverse()];
    },
  });
  const columns: ProColumns<any>[] = [
    {
      title: '序号',
      width: 60,
      render: (_, __, index) => index + 1,
    },
    {
      title: '文档名称',
      ellipsis: true,
      dataIndex: 'fileName',
    },
    {
      title: '创建时间',
      width: 200,
      dataIndex: 'gmtCreate',
    },
    {
      title: '状态',
      width: 100,
      dataIndex: 'status',
    },
    {
      title: '操作',
      width: 100,
      dataIndex: 'operate',
      fixed: 'right',
      render: (text, record) => {
        return (
          <Space size="small" className={styles.spaceWrap}>
            {/* <a
              onClick={() => {
             
              }}>分段详情</a> */}
            <a
              onClick={() => {
                getFileTaskPageContent.run({ fileCode: record.fileCode });
                drawerTaskToggle();
              }}
            >
              任务详情
            </a>
            {/* <Popconfirm
              key="delete"
              title="确认是否删除？"
              onConfirm={() => {
                // deleteRule.run(record.id)
              }}>
              <a style={{ color: '#f02323' }}>删除</a>
            </Popconfirm> */}
          </Space>
        );
      },
    },
  ];
  const taskColumns: ColumnsType<any> = [
    {
      title: '入库环境',
      width: 126,
      ellipsis: true,
      dataIndex: 'saveNode',
    },
    {
      title: '描述',
      width: 120,
      ellipsis: true,
      dataIndex: 'taskDescription',
    },
    {
      title: '重试次数',

      width: 100,
      dataIndex: 'restartNum',
    },
    {
      title: '创建时间',

      width: 162,
      dataIndex: 'createTime',
    },
    {
      title: '完成时间',
      width: 162,
      dataIndex: 'finishTime',
    },
  ];

  return (
    <div className={styles.detailContainer}>
      <Drawer
        title={`知识库详情`}
        destroyOnHidden={true}
        width={900}
        open={drawerDetail}
        onClose={drawerDetailToggle}
        // footer={
        //   <Space>
        //     <Button
        //       onClick={() => {
        //         drawerDetailToggle();
        //       }}
        //     >
        //       取消
        //     </Button>
        //   </Space>
        // }
      >
        {/* <TableData data={getFilePageContent.data} columns={columns} /> */}
        <ProTable
          {...proTableConfig}
          columns={columns}
          request={getFilePageContent.runAsync}
          size="middle"
          rowKey="id"
          ghost={true}
          search={false}
        />
        <Drawer
          title="知识库详情-任务详情"
          width={850}
          destroyOnHidden={true}
          open={drawerTask}
          onClose={drawerTaskToggle}
        >
          <TableData data={getFileTaskPageContent?.data?.data ?? []} columns={taskColumns} />
        </Drawer>
      </Drawer>
    </div>
  );
};
